home *** CD-ROM | disk | FTP | other *** search
/ Clickx 63 / Clickx 63.iso / software / multimedia / mirov204 / Miro_Installer.exe / xulrunner / chrome / toolkit.jar / content / global / crashes.xhtml < prev    next >
Encoding:
Extensible Markup Language  |  2008-02-04  |  6.0 KB  |  206 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  3.     "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
  4. [
  5.   <!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
  6.   <!ENTITY % crashesDTD SYSTEM "chrome://global/locale/crashes.dtd">
  7.   %globalDTD;
  8.   %crashesDTD;
  9. ]>
  10.  
  11. <html xmlns="http://www.w3.org/1999/xhtml">
  12. <head>
  13. <style type="text/css">
  14. :root {
  15.   font-family: sans-serif;
  16. }
  17. table {
  18.   padding-bottom: 2em;
  19. }
  20. th {
  21.   text-align: left;
  22.   white-space: nowrap;
  23. }
  24. /* name */
  25. th:first-child {
  26.   -moz-padding-end: 2em;
  27. }
  28. /* date */
  29. td:first-child + td {
  30.   -moz-padding-start: 1em;
  31.   -moz-padding-end: .5em;
  32.   white-space: nowrap;
  33. }
  34. /* time */
  35. td:last-child {
  36.   -moz-padding-start: .5em;
  37.   white-space: nowrap;
  38. }
  39. .clear-reports {
  40.   float: right;
  41. }
  42.  
  43. th[chromedir="rtl"] {
  44.   text-align: right;
  45. }
  46. .clear-reports[chromedir="rtl"] {
  47.   float: left;
  48. }
  49. </style>
  50. <link rel="stylesheet" media="screen, projection" type="text/css"
  51.       href="chrome://global/skin/dirListing/dirListing.css"/>
  52. <script type="application/javascript">
  53. <![CDATA[
  54. const Cc = Components.classes;
  55. const Ci = Components.interfaces;
  56.  
  57. var reportsDir;
  58.  
  59. function findInsertionPoint(reports, date) {
  60.   if (reports.length == 0)
  61.     return 0;
  62.  
  63.   var min = 0;
  64.   var max = reports.length - 1;
  65.   while (min < max) {
  66.     var mid = parseInt((min + max) / 2);
  67.     if (reports[mid].date < date)
  68.       max = mid - 1;
  69.     else if (reports[mid].date > date)
  70.       min = mid + 1;
  71.     else
  72.       return mid;
  73.   }
  74.   if (reports[min].date <= date)
  75.     return min;
  76.   return min+1;
  77. }
  78.  
  79. function populateReportList() {
  80.   var prefService = Cc["@mozilla.org/preferences-service;1"].
  81.                     getService(Ci.nsIPrefBranch);
  82.  
  83.   var reportURL = null;
  84.   try {
  85.     reportURL = prefService.getCharPref("breakpad.reportURL");
  86.     // Ignore any non http/https urls
  87.     if (!/^https?:/i.test(reportURL))
  88.       reportURL = null;
  89.   }
  90.   catch (e) { }
  91.   if (!reportURL) {
  92.     document.getElementById("reportList").style.display = "none";
  93.     document.getElementById("noConfig").style.display = "block";
  94.     return;
  95.   }
  96.   var directoryService = Cc["@mozilla.org/file/directory_service;1"].
  97.                          getService(Ci.nsIProperties);
  98.  
  99.   reportsDir = directoryService.get("UAppData", Ci.nsIFile);
  100.   reportsDir.append("Crash Reports");
  101.   reportsDir.append("submitted");
  102.  
  103.   var reports = [];
  104.   if (reportsDir.exists() && reportsDir.isDirectory()) {
  105.     var entries = reportsDir.directoryEntries;
  106.     while (entries.hasMoreElements()) {
  107.       var file = entries.getNext().QueryInterface(Ci.nsIFile);
  108.       var leaf = file.leafName;
  109.       if (leaf.substring(0, 3) == "bp-" &&
  110.           leaf.substring(leaf.length - 4) == ".txt") {
  111.         var entry = {
  112.           id: leaf.substring(3, leaf.length - 4),
  113.           date: file.lastModifiedTime
  114.         };
  115.         var pos = findInsertionPoint(reports, entry.date);
  116.         reports.splice(pos, 0, entry);
  117.       }
  118.     }
  119.   }
  120.  
  121.   if (reports.length == 0) {
  122.     document.getElementById("reportList").style.display = "none";
  123.     document.getElementById("noReports").style.display = "block";
  124.     return;
  125.   }
  126.  
  127.   var formatter = Cc["@mozilla.org/intl/scriptabledateformat;1"].
  128.                   createInstance(Ci.nsIScriptableDateFormat);
  129.   var body = document.getElementById("tbody");
  130.   for (var i = 0; i < reports.length; i++) {
  131.     var row = document.createElement("tr");
  132.     var cell = document.createElement("td");
  133.     row.appendChild(cell);
  134.     var link = document.createElement("a");
  135.     link.setAttribute("href", reportURL + reports[i].id);
  136.     link.appendChild(document.createTextNode(reports[i].id));
  137.     cell.appendChild(link);
  138.  
  139.     var date = new Date(reports[i].date);
  140.     cell = document.createElement("td");
  141.     var datestr = formatter.FormatDate("",
  142.                                        Ci.nsIScriptableDateFormat.dateFormatShort,
  143.                                        date.getFullYear(),
  144.                                        date.getMonth() + 1,
  145.                                        date.getDate());
  146.     cell.appendChild(document.createTextNode(datestr));
  147.     row.appendChild(cell);
  148.     cell = document.createElement("td");
  149.     var timestr = formatter.FormatTime("",
  150.                                        Ci.nsIScriptableDateFormat.timeFormatNoSeconds,
  151.                                        date.getHours(),
  152.                                        date.getMinutes(),
  153.                                        date.getSeconds());
  154.     cell.appendChild(document.createTextNode(timestr));
  155.     row.appendChild(cell);
  156.     body.appendChild(row);
  157.   }
  158. }
  159.  
  160. function clearReports() {
  161.   var bundles = Cc["@mozilla.org/intl/stringbundle;1"].
  162.                 getService(Ci.nsIStringBundleService);
  163.   var bundle = bundles.createBundle("chrome://global/locale/crashes.properties");
  164.   var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"].
  165.                 getService(Ci.nsIPromptService);
  166.   if (!prompts.confirm(window,
  167.                        bundle.GetStringFromName("deleteconfirm.title"),
  168.                        bundle.GetStringFromName("deleteconfirm.description")))
  169.     return;
  170.  
  171.   var entries = reportsDir.directoryEntries;
  172.   while (entries.hasMoreElements()) {
  173.     var file = entries.getNext().QueryInterface(Ci.nsIFile);
  174.     var leaf = file.leafName;
  175.     if (leaf.substring(0, 3) == "bp-" &&
  176.         leaf.substring(leaf.length - 4) == ".txt") {
  177.       file.remove(false);
  178.     }
  179.   }
  180.   document.getElementById("reportList").style.display = "none";
  181.   document.getElementById("noReports").style.display = "block";
  182. }
  183. ]]>
  184. </script>
  185. <title>&crashes.title;</title>
  186. </head><body onload="populateReportList()" dir="&locale.dir;">
  187. <button chromedir="&locale.dir;" class="clear-reports"
  188.         onclick="clearReports()">&clearReports.label;</button>
  189. <h1>&crashes.title;</h1>
  190. <div id="reportList">
  191.   <table>
  192.     <thead>
  193.       <tr>
  194.         <th chromedir="&locale.dir;">&id.heading;</th>
  195.         <th chromedir="&locale.dir;" colspan="2">&date.heading;</th>
  196.       </tr>
  197.     </thead>
  198.     <tbody id="tbody">
  199.     </tbody>
  200.   </table>
  201. </div>
  202. <p id="noReports" style="display: none">&noReports.label;</p>
  203. <p id="noConfig" style="display: none">&noConfig.label;</p>
  204. </body>
  205. </html>
  206.